package ink.teamwork.battery.controller

import ink.teamwork.battery.model.InviteResponse
import ink.teamwork.battery.model.LoginRequest
import ink.teamwork.battery.model.Result
import ink.teamwork.battery.service.UserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/user")
class UserController : BaseController() {

    @Autowired
    lateinit var userService: UserService

    @PostMapping("/login")
    fun login(@RequestBody request: LoginRequest): Result {
        return userService.login(request)
    }

    @GetMapping("/info")
    fun info(): Result {
        return Result.success(getCurrentUser())
    }

    @GetMapping("/invite")
    fun invite(): List<InviteResponse> {
        return userService.getInviteList(getCurrentUser().openId)
    }



}